package org.icdio.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.icdio.dao.Image;
import org.icdio.utils.DBUtils;


import org.icdio.entity.*;;

public class ImageImpl implements Image{
	
	Connection conn = null;
	

	@Override
	public ImageEntity getImage(Integer id) throws Exception {
		conn = DBUtils.open();

		ImageEntity image = new ImageEntity();
		
		String sql = "SELECT * FROM picurl where id = ?";
		
		PreparedStatement pre = conn.prepareStatement(sql);
		
		pre.setInt(1, id);
		
		ResultSet resultSet = pre.executeQuery();
		
		
		while(resultSet.next()) {
			image.setImage_id(resultSet.getString(1));
			image.setImage_url(resultSet.getString(2));
			image.setImage_name(resultSet.getString(3));
			image.setImage_size(resultSet.getString(4));
			image.setImage_type(resultSet.getString(5));
		}
		
		return image;
	}

}
